package makovo.ajax;

import java.io.IOException;
import java.io.Serializable;
import java.sql.SQLException;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import makovo.data.Resources;
import makovo.entities.Applicant;
import makovo.entities.ApplicantWithDocs;
import makovo.entities.Project;
import makovo.entities.SocInfo;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;

public class ApplicantDetails extends ActionSupport implements ServletRequestAware, Serializable, SessionAware {

	private static final long serialVersionUID = 1L;
	private HttpServletRequest mRequest;
	private Map<String, Object> mSession;
	private Applicant applicant;
	private ApplicantWithDocs applicantInfo;
	private SocInfo socInfo;
	private Project project;
	private int step;
	private String mCurp;

	public Applicant getApplicantInfo() {
		return this.applicantInfo;
	}

	public SocInfo getSocInfo() {
		return this.socInfo;
	}

	public Project getProject() {
		return this.project;
	}

	public int getStep() {
		return this.step;
	}

	public Applicant getApplicant() {
		return this.applicant;
	}

	public String getApplicantDetails() {
		try {
			applicantInfo = Resources.getApplicantWithDocs(mCurp);
			socInfo = Resources.getSocInfoByCURP(mCurp);
			project = Resources.getProjectInfoByCURP(mCurp);
			step = applicantInfo.step;
		} catch (Exception e) {
			e.printStackTrace();
		}

		return ActionSupport.SUCCESS;
	}
	
	public String getApplicantReg() {
		try {
			this.applicant = Resources.getApplicantInfoByCURP(mCurp);
		} catch (Exception e) {
			e.printStackTrace();
		}

		return ActionSupport.SUCCESS;
	}

	@Override
	public void setServletRequest(HttpServletRequest request) {
		this.mRequest = request;
	}

	@Override
	public void setSession(Map<String, Object> sessionInfo) {
		this.mSession = sessionInfo;
		mCurp = (String) this.mSession.get("User.idSender");
	}

}
